using System.Collections;

using UnityEngine;

namespace XyzCode.Scenes 
{
    /// <summary>
    /// 演示场景
    /// </summary>
    public class DemoScene : MonoBehaviour
    {
        /// <summary>
        /// Start
        /// </summary>
        private void Start()
        {
            StartCoroutine(LoopMoveLight_0_XC());
        }

        /// <summary>
        /// 循环移动灯光
        /// </summary>
        /// <returns>枚举迭代器</returns>
        private IEnumerator  LoopMoveLight_0_XC()
        {
            var goLight0 = GameObject.Find("/LightGroup/Light_0");

            if (null == goLight0)
            {
                yield break;
            }

            var origPos = goLight0.transform.position;
            var waitObj = new WaitForEndOfFrame();
            
            while (true)
            {
                yield return waitObj;

                if (goLight0.transform.position.x > 7)
                {
                    goLight0.transform.position = origPos;
                    continue;
                }
                
                goLight0.transform.Translate(Vector3.right * (3 * Time.deltaTime));
            }
        }
    }
}
